

function indexjs(){



function daojishi(oDate2) {
    let daojishitxt = document.getElementById("daojishitxt");
    let djs = daojishitxt.children;
    let oDate1 = new Date();

    let ss = Math.floor((oDate2 - oDate1) / 1000);


    let Hours = Math.floor(ss / 3600 % 24);
    let Minute = Math.floor(ss / 60 % 60);
    let Seconds = Math.floor(ss % 60);
    Seconds = Seconds < 10 ? "0" + Seconds : Seconds;
    Minute = Minute < 10 ? "0" + Minute : Minute;
    Hours = Hours < 10 ? "0" + Hours : Hours;
    djs[0].innerText = Hours;
    djs[1].innerText = Minute;
    djs[2].innerText = Seconds;

};

function biglunbo() {
    let count = 0;
    let timer1 = null;
    let $btn = $("#bigbtn>button");
    let $slb = $("#blbt>li");
    slider();
    $("#biglunbo").hover(function () {
        clearInterval(timer1);
        $("#blbs li").mouseover(function () {
            let oIndex = $(this).index();
            $("#blbs li").eq(oIndex).addClass("select").siblings().removeClass("select");
            $("#blbt li").eq(oIndex).stop().fadeIn(500)
                .siblings().fadeOut(500);
        })
        $btn.eq(0).click(function () {
            count--;
            if (count == -1) {
                count = $slb.length - 1;
            };
            $("#blbt li").eq(count).fadeIn(800)
                .siblings().fadeOut(800);
            $("#blbs li").eq(count).addClass("select").siblings().removeClass("select");

        });
        $btn.eq(1).click(function () {
            count++;
            if (count == $slb.length) {
                count = 0;
            };
            $("#blbt li").eq(count).fadeIn(800)
                .siblings().fadeOut(800);
            $("#blbs li").eq(count).addClass("select").siblings().removeClass("select");
        });

    }, function () {
        slider();
    });

    function slider() {
        timer1 = setInterval(function () {
            count++;
            if (count == $("#blbt li").length) {
                count = 0;
            }
            $("#blbt li").eq(count).fadeIn(800)
                .siblings().fadeOut(800)
            $("#blbs li").eq(count).addClass("select").siblings().removeClass("select")

        }, 3000);
    }





};

function smalunbo() {
    let count = null;
    let timer2 = null;
    let $btn = $("#smalunbo>div>button");
    let $slb = $("#smalunbo>ul>li");
    move();
    $("#smalunbo").hover(function () {
        clearInterval(timer2);
        $btn.show();
        $btn.eq(0).click(function () {
            count--;
            if (count == -1) {
                count = $slb.length - 1;
            };
            $slb.eq(count).show().siblings().hide();

        });
        $btn.eq(1).click(function () {
            count++;
            if (count == $slb.length) {
                count = 0;
            };

            $slb.eq(count).show().siblings().hide();
        });
    }, function () {
        $btn.hide();
        move();
    });



    function move() {
        timer2 = setInterval(function () {
            count++;
            if (count == $slb.length) {
                count = 0;
            }
            $slb.eq(count).show().siblings().hide();
        }, 2000);
    }





};

function louti() {

    $(window).scroll(function () {
        let scro = $(window).scrollTop();
        let st = $(".miaosha").offset().top;
        let jlt = Math.abs(scro-st);
        if (st <= scro) {
            $(".tiaozhuan").css({
                "top": scro - 600 + "px",
            });
            $(".tiaozhuan-7").show();
        } else {
            $(".tiaozhuan").css({
                "top": 0,
            });
            $(".tiaozhuan-7").hide();
        }
    })


}

 //倒计时
 var oDate = new Date("2021-09-1 12:00:00");
 daojishi(oDate);
 var timer = setInterval(function () {
     daojishi(oDate);
 }, 1000);

 //轮播
 // $("#biglunbo")
 biglunbo();
 smalunbo();
 louti();
 $(".zhuce").click(function(){
     location.href="./html/login.html";
 });
 $(".denglu").click(function(){
     location.href="./html/register.html";
     console.log("a");
 });






//  Initialize Swiper
 var swiper1 = new Swiper('.swiper-container-1', {
    pagination: {
      el: '.swiper-pagination',
      clickable: true,
    },
    loop:true,
    autoplay:{
        delay: 3000,
    },
    hashNavigation: true,
  });



  let swiper2 = new Swiper('.swiper-container-2', {
    slidesPerGroup:4,
    slidesPerView: 4,
    spaceBetween: 2,
    autoplay:false,
    loop:true,
    navigation: {
    nextEl: '.swiper-button-next',
    prevEl: '.swiper-button-prev',
  },
    pagination: {
    //   el: '.swiper-pagination',
      // clickable: true,
    },
  });




//上传数据：到 用户"38306"    
$(".shangchuanshuju").click(function () {
    location.href="./html/addproduct.html"
});
$("#houtaiguanlixiyong").click(function () {
    location.href="./html/htglxt.html"
});


//为你推荐啦啦！！！     //快来抢购吧！！！
$.ajax({
    type: "get",
    url: "http://jx.xuzhixiang.top/ap/api/allproductlist.php",
    data: {
        pagenum:"20",
        pagesize:"18"
    },
    success: function (data) {
        var data = data.data;
        var str = "";
        for (let i = 0; i < data.length; i++) {
            str += `
                <div class="wntjlll" data-id="${data[i].pid}">
                    <img  src="${data[i].pimg}" alt="">
                    <p>${data[i].pname}</p>
                    <div>
                        <span><i>￥</i><span>${data[i].pprice}</span></span>
                        <span><i>￥</i><span>80.00</span></span>
                    </div> 
                </div>     
            `;
        };
        $(".weini-main").html(str);


        $(".wntjlll").click(function () {
            console.log("a");
            var prodid = $(this).data("id");
            location.href = "html/detail.html?pid=" + prodid;
        });



        var str1 = "";
        for (var i = 0; i < 18; i++) {
            str1 += `
                <div class="klqgb">
                    <img data-id="${data[i].pid}" src="${data[i].pimg}" alt="">
                    <p>快来抢购吧</p>
                    <div>￥9.9</div>
                </div>     
            `;
        };
        $(".pindao-main").html(str1);
        //点击进入详情页
        $(".klqgb").click(function () {
            var prodid = $(this).find("img").data("id");
            console.log(prodid);
            location.href = "html/detail.html?pid=" + prodid;
        });


    },
});

   //为你推荐啦啦！！！  //动画   //新品
   $.ajax({
    type: "get",
    url: "http://jx.xuzhixiang.top/ap/api/allproductlist.php",
    data: {
        pagenum:"20",
        pagesize:"18"
    },
    success: function (data) {
        var data = data.data;
        var str = "";
        var str7 = "";
        var str1 = "";
        for (var i = 0; i < data.length; i++) {
            str += `
                <div class="wntjlll" data-id="${data[i].pid}">
                    <img src="${data[i].pimg}" alt="">
                    <p>${data[i].pname}</p>
                    <div>
                        <span><i>￥</i><span>${data[i].pprice}</span></span>
                        <span><i>￥</i><span>80.00</span></span>
                    </div> 
                </div>     
            `;

        };
        for (var i = 5; i < data.length; i++) {
            str7 += `
            <li class="dh-1" data-id="${data[i].pid}">
                <img src="${data[i].pimg}" alt="图片">
                <p> 商品：${data[i].pname}</p>
                <p> ￥${data[i].pprice}</p>
            </li>
        `; 
        };
        for(var i=9;i<13;i++){
            str1 += `
            <div data-id="${data[i].pid}">
                <img src="${data[i].pimg}" alt="">
                <p>商品：${data[i].pname}</p>
                <p>￥${data[i].pprice}</p>
            </div>
            `;
        }
        $(".weini-main").html(str);
        $("#donghua").html(str7);
        $(".xinpin").html(str1);

        $(".wntjlll").click(function () {
            console.log("a");
            var prodid = $(this).data("id");
            location.href = "html/detail.html?pid=" + prodid;
        });

        $("#donghua>li").click(function () {
            var prodid = $(this).data("id");
            location.href = "html/detail.html?pid=" + prodid;

        });
        $(".xinpin>div").click(function () {
            var prodid = $(this).data("id");
            location.href = "html/detail.html?pid=" + prodid;

        });



    },
});

$.ajax({
    type: "get",
    url: "http://jx.xuzhixiang.top/ap/api/allproductlist.php",
    data: {
        pagenum:"20",
        pagesize:"18"
    },
    success: function (data) {

        var data = data.data;
        var str1 = "";
        var str2 = "";
        var str3 = "";
        var str4 = "";
        var str5 = "";
        var str6 = "";
        for (var i = 0; i < data.length; i++) {

            if (i >= 0 && i < 5) {
                str1 += `
                <div class="detailpage" data-id="${data[i].pid}">
                    <img src="${data[i].pimg}" alt="">
                    <p>商品：${data[i].pname}</p>
                    <p>￥${data[i].pprice}</p>
                </div>        
            `;
            }
            if (i >= 8 && i < 13) {
                str5 += `
                <div class="detailpage"  data-id="${data[i].pid}">
                    <img src="${data[i].pimg}" alt="">
                    <p>商品：${data[i].pname}</p>
                    <p>￥${data[i].pprice}</p>
                </div>        
            `;
            }
            if (i >= 5 && i < 10) {
                str2 += `
                <div class="detailpage" data-id="${data[i].pid}">
                    <img src="${data[i].pimg}" alt="">
                    <p>商品：${data[i].pname}</p>
                    <p>￥${data[i].pprice}</p>
                </div>        
            `;
            }
            if (i >= 10 && i < 15) {
                str3 += `
                <div class="detailpage"  data-id="${data[i].pid}">
                    <img src="${data[i].pimg}" alt="">
                    <p>商品：${data[i].pname}</p>
                    <p>￥${data[i].pprice}</p>
                </div>        
            `;
            }
            if (i >= 15 && i < 20) {
                str4 += `
                <div class="detailpage" data-id="${data[i].pid}">
                    <img src="${data[i].pimg}" alt="">
                    <p>商品：${data[i].pname}</p>
                    <p>￥${data[i].pprice}</p>
                </div>        
            `;
            }
         


        };
        $(".main-1").html(str1);
        $(".main-2").html(str2);
        $(".main-3").html(str3);
        $(".main-4").html(str4);
        $(".main-5").html(str5);


        $(".detailpage").click(function () {
            var prodid = $(this).data("id");
            console.log("aa")
            location.href = "html/detail.html?pid=" + prodid;

        });
        $("#blbt>li").click(function () {
            var prodid = $(this).data("id");
            location.href = "html/detail.html?pid=" + prodid;

        });





    }
});

 

















}




